# Contributor: Dhruvin Gandhi <contact@dhru.vin>
# Maintainer: Dhruvin Gandhi <contact@dhru.vin>
pkgname=do-agent
pkgver=3.16.9
_git_rev=1bdbf1a95cab594fb29c2d354f71f029e9c8624f
pkgrel=0
pkgdesc="Collects system metrics from DigitalOcean Droplets"
url="https://github.com/digitalocean/do-agent"
arch="x86_64"  # limited by digital ocean
license="Apache-2.0"
makedepends="go"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://github.com/digitalocean/do-agent/archive/refs/tags/$pkgver/do-agent-$pkgver.tar.gz
	do-agent.initd
	do-agent.confd"

build() {
	go build -ldflags "-X 'main.version=$pkgver' -X 'main.revision=$_git_rev' -X 'main.buildDate=$(date)'" \
		-o bin/do-agent ./cmd/do-agent
}

check() {
	go test -v ./...
}

package() {
	install -Dm755 bin/do-agent "$pkgdir/usr/sbin/do-agent"
	install -Dm644 LICENSE "$pkgdir/usr/share/doc/do-agent/LICENSE"
	install -Dm755 "$srcdir/do-agent.initd" "$pkgdir/etc/init.d/do-agent"
	install -Dm644 "$srcdir/do-agent.confd" "$pkgdir/etc/conf.d/do-agent"
}

sha512sums="
90418343a49fb3312abc63c8913d644a12a44a372a25028cee211dacefe626c35c1586b98a6a50b733ac56db6a2d4f2446349ac66ebc4d2fbed3a179c8e21bf3  do-agent-3.16.9.tar.gz
cb89ceeb17767f1cf30055649d7f1fa1496a6a763b23c501a440bea871d6f43abec8901d5ab18d96b170bb95c374c2f5e468fd12496178d218cd13ab299527c4  do-agent.initd
3ad8d9223de1c99c1f231ca9b6500f932c14fbea38093d28231c6c805632ae0594dfd20dba678061e07ae13e8b0d20cc79185fd05b17522f69b768178866347c  do-agent.confd
"
